//package org.voice;
//
//import com.sun.jna.Library;
//import com.sun.jna.Native;
//import com.sun.jna.Pointer;
//import com.sun.jna.platform.win32.COM.COMUtils;
//import com.sun.jna.platform.win32.COM.IUnknown;
//import com.sun.jna.platform.win32.Guid;
//import com.sun.jna.platform.win32.Ole32;
//import com.sun.jna.platform.win32.WinNT;
//import com.sun.jna.ptr.PointerByReference;
//import com.sun.jna.win32.StdCallLibrary;
//
//// JNA Microsoft SAPI
//public class TextToSpeechSAPI {
//    public interface SpVoice extends StdCallLibrary {
//        int Speak(String text, int flags, Pointer reserved);
//    }
//
//    public static void main(String[] args) {
//        // 初始化 COM 库
//        Ole32.INSTANCE.CoInitializeEx(null, Ole32.COINIT_MULTITHREADED);
//
//        try {
//            // 创建 SpVoice 对象
//            Guid.CLSID clsid = new Guid.CLSID("{C866CA3A-32F7-11D2-9602-00C04F8EE628}");
//            Guid.IID iid = new Guid.IID("{C4F17F61-68CA-11D2-9602-00C04F8EE628}");
//            PointerByReference ppv = new PointerByReference();
////            WinNT.HRESULT hr = Ole32.INSTANCE.CoCreateInstance(clsid, null, Ole32.CLSCTX_INPROC_SERVER, iid, ppv);
//            WinNT.HRESULT hr = Ole32.INSTANCE.CoCreateInstance(clsid, null, Ole32.RPC_C_AUTHN_LEVEL_CALL, iid, ppv);
//            COMUtils.checkRC(hr);
//
//            // 获取 SpVoice 接口
//            SpVoice voice = Native.load(ppv.getValue(), SpVoice.class);
//
//            // 要转换的文本
//            String text = "Hello, this is a text-to-speech example using Windows SAPI.";
//            // 合成语音
//            voice.Speak(text, 0, null);
//
//            // 释放对象
//            IUnknown unk = new IUnknown(ppv.getValue());
//            unk.Release();
//        } finally {
//            // 释放 COM 库
//            Ole32.INSTANCE.CoUninitialize();
//        }
//    }
//}
